document.addEventListener('DOMContentLoaded', function() {
    const tabs = document.querySelectorAll('.login-tab');
    const forms = document.querySelectorAll('.login-form');

    tabs.forEach(tab => {
        tab.addEventListener('click', function() {
            const tabType = this.getAttribute('data-tab');
            
            tabs.forEach(t => t.classList.remove('active'));
            this.classList.add('active');
            
            forms.forEach(form => form.classList.remove('active'));
            document.getElementById(`${tabType}LoginForm`).classList.add('active');
        });
    });

    document.getElementById('loginButton').addEventListener('click', function() {
        const username = document.getElementById('username').value;
        const password = document.getElementById('password').value;

        if (username && password) {
            alert('密码登录成功！');
            window.location.href = 'index.html';
        } else {
            alert('请输入有效的账号和密码。');
        }
    });

    document.getElementById('smsLoginButton').addEventListener('click', function() {
        const phone = document.getElementById('phone').value;
        const smsCode = document.getElementById('smsCode').value;

        if (phone && smsCode) {
            alert('短信登录成功！');
            window.location.href = 'index.html';
        } else {
            alert('请输入有效的手机号和验证码。');
        }
    });

    document.getElementById('getSmsCode').addEventListener('click', function() {
        alert('验证码已发送！');
    });
});